const app = getApp();
var WxParse = require('../../../wxParse/wxParse.js');
Page({
  data: {
    num: 1,
  },
  onLoad: function (options) {
    var that = this;
    that.setData({
      options: options
    })
  },
  onShow:function(){
    var that = this;
    var goods_id = that.data.options.id;
    wx.showLoading({
      title: '加载中...',
    })
    app.request('score.product/goodsDetail', { goods_id }, 'GET', false, function (res) {
      wx.setNavigationBarTitle({
        title: res.data.data.goods_name,
      })
      that.setData({
        pageShow: true,
        goods: res.data.data,
        editor: WxParse.wxParse('editor', 'html', res.data.data.content, that, 5),
      })
    })
  },
  skipPage:function(e){
    app.skipPage(e)
  },
  numChoose(e){
    let that = this;
    let type = e.currentTarget.dataset.type;
    let limit_once = that.data.goods.limit_once;
    let num = that.data.num;
    if(type == 'reduce'){
      num = num>1 ? num-1 : num;
    }else{
      if (limit_once>0){
        num = num < limit_once ? num+1 : num;
      }else{
        num++;
      }
    }
    that.setData({
      num:num,
    })
  },
  onReachBottom: function () {

  },
  onShareAppMessage: function () {

  }
})